package com.wjl.partnerMatching;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@MapperScan("com.wjl.partnerMatching.mapper")
public class PartnerMatchingProgramApplication implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        // 进行跨域配置
        // 前端占用80 后端占用8080
        // 两个端口之间的访问就是跨域
        // 防止跨域报错
        registry.addMapping("/**")
                .allowedOriginPatterns("*")
                .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
                // 是否允许带 cookie 访问
                .allowCredentials(true)
                // 预检请求的缓存时间，单位秒 s
                .maxAge(3600)
                .allowedHeaders("*");
    }

    public static void main(String[] args) {

        SpringApplication.run(PartnerMatchingProgramApplication.class, args);
    }

}
